//
//  LoginViewController.m
//  GoodWayClient
//
//  Created by HuiDong on 15/12/2.
//  Copyright © 2015年 HuiDong. All rights reserved.
//

#import "LoginViewController.h"

@interface LoginViewController ()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UIImageView *backgroundImageView;
@property (weak, nonatomic) IBOutlet UIImageView *logoImageView;
@property (weak, nonatomic) IBOutlet UITextField *userText;
@property (weak, nonatomic) IBOutlet UITextField *psdText;


//登录方法
- (IBAction)loginBtn:(UIButton *)sender;
//密码重置方法
- (IBAction)ResetPsd:(UIButton *)sender;
//记住密码状态改变方法
- (IBAction)RememberPsd:(id)sender;


//额外添加
@property (nonatomic, assign) int a;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置文本框样式
    UIImageView *user = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user.png"]];
    user.frame = CGRectMake(0, 0, self.userText.frame.size.height*0.5, self.userText.frame.size.height*0.5);
    
    self.userText.leftView = user;
    self.userText.leftViewMode = UITextFieldViewModeAlways;
    self.userText.clearButtonMode = UITextFieldViewModeAlways;//输入时出现叉号，用于一次性删除文本框里面的内容
    
    UIImageView *psd = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"password.png"]];
    psd.frame = CGRectMake(0, 0, self.userText.frame.size.height*0.5, self.userText.frame.size.height*0.5);
    self.psdText.leftView = psd;
    self.psdText.leftViewMode = UITextFieldViewModeAlways;
    self.psdText.clearButtonMode = UITextFieldViewModeAlways;//输入时出现叉号，用于一次性删除文本框里面的内容
    
    //设置代理,为下面textField的键盘收回打基础
    self.userText.delegate = self;
    self.psdText.delegate = self;
}

//return键返回响应
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

//登录方法
- (IBAction)loginBtn:(UIButton *)sender {
    
}

//密码重置方法
- (IBAction)ResetPsd:(UIButton *)sender {
  
}

//记住密码状态改变方法
- (IBAction)RememberPsd:(UIButton *)sender {
    if (self.a == 0) {
        [sender setBackgroundImage:[UIImage imageNamed:@"icon_user"] forState:UIControlStateNormal];
        self.a = 1;
    }else
    {
        [sender setBackgroundImage:[UIImage imageNamed:@"psd"] forState:UIControlStateNormal];
        self.a = 0;
    }
}
@end
